springcloud之Feign(nacos组件中的)调用超时问题(feign.RetryableException: Read timed out executing GET http://)

您所在的位置:网站首页 read timed springcloud之Feign(nacos组件中的)调用超时问题(feign.RetryableException: Read timed out executing GET http://)

springcloud之Feign(nacos组件中的)调用超时问题(feign.RetryableException: Read timed out executing GET http://)

2024-06-23 13:54| 来源: 网络整理| 查看: 265

报错日志如下:

12345Binary data 2020-11-11 19:47:07.894 ERROR c.n.c.c.r.e.GlobalExceptionHandler:72 - errorMsg=Read timed out executing GET http://XXXXXXX,innerCode=5000,exception={} feign.RetryableException: Read timed out executing GET http:// XXXXXXXX     at feign.FeignException.errorExecuting(FeignException.java:132)     at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMet 解决方案

首先,我们看下Feign的简介

Feign 是一个声明式的web服务客户端,这便得编写web服务客户端更容易,使用Feign 创建一个接口并对它进行注解,它具有可插拔的注解支持包括Feign注解与JAX-RS注解,Feign还支持可插拔的编码器与解码器,Spring Cloud 增加了对 Spring MVC的注解,Spring Web 默认使用了HttpMessageConverters, Spring Cloud 集成 Ribbon 和 Eureka 提供的负载均衡的HTTP客户端 Feign.

即,Feign接口调用分两层,Ribbon的调用和Hystrix调用,理论上设置Ribbon的时间即可,但是Ribbon的超时时间和Hystrix的超时时间需要结合起来,按照木桶原则最低的就是Feign的超时时间,建议最好配置超时时间一致。经过配置一下application设置后,完美解决了问题。因为第三方接口中需要3~50秒不等的时间,所以这个数值也是根据自己的业务系统情况设置的。

看了下配置文件,好像配置了时间相关的参数,中间带有横杠 "-", 比如:read-timeout ,仔细一查,此类参数在nacos环境下失效,只能用 ReadTimeout 这种,试了一下果然如此,成功解决。

application.yml 1234567#ribbon的超时时间 ribbon:   # read-timeout: 60000  失效参数   # connect-timeout: 60000  失效参数   ReadTimeout: 60000   ConnectTimeout: 60000


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3